package com.hzf.material.rpc.service.impl;

import com.github.wenhao.geohash.domain.GeoRange;
import com.hzf.material.dao.mapper.*;
import com.hzf.material.dao.model.*;
import com.hzf.material.rpc.api.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * describe: TODO
 * creat_user: 白开水
 * creat_time: 2017/11/18   9:25
 **/
public class MaterialApiServiceImpl implements MaterialApiService{

    @Autowired
    private MaterialAreaMapper materialAreaMapper;

    @Autowired
    private MaterialListMapper materialListService;

    @Autowired
    private MaterialListTypeMapper materialListTypeService;

    @Autowired
    private MaterialGoodsModelPinService materialGoodsModelPinService;

    @Autowired
    private MaterialGoodsModelService materialGoodsModelService;

    @Autowired
    private MaterialGoodsPicMapper materialGoodsPicService;

    @Autowired
    private MaterialGoodsService materialGoodsService;

    @Autowired
    private MaterialGoodsTypeBigService materialGoodsTypeBigService;

    @Autowired
    private MaterialGoodsTypeMiddleService materialGoodsTypeMiddleService;

    @Autowired
    private MaterialGoodsTypeSmallService materialGoodsTypeSmallService;
    @Autowired
    private MaterialShopMapper materialShopMapper;
    @Autowired
    private MaterialGoodsMapper materialGoodsMapper;
    @Override
    public List<MaterialArea> selectByExample(MaterialAreaExample materiaAreaExample) {
        return materialAreaMapper.selectByExample(materiaAreaExample);
    }

    @Override
    public List<MaterialList> selectByExample(MaterialListExample materialListExample) {
        return materialListService.selectByExample(materialListExample);
    }

    @Override
    public List<MaterialListType> selectByExample(MaterialListTypeExample materialListTypeExample) {
        return materialListTypeService.selectByExample(materialListTypeExample);
    }




    @Override
    public List<MaterialGoodsModelPin> selectByExample(MaterialGoodsModelPinExample materialGoodsModelPinExample) {
        return materialGoodsModelPinService.selectByExample(materialGoodsModelPinExample);
    }

    @Override
    public List<MaterialGoodsModel> selectByExample(MaterialGoodsModelExample materialGoodsModelExample) {
        return materialGoodsModelService.selectByExample(materialGoodsModelExample);
    }

    @Override
    public List<MaterialGoodsPic> selectByExample(MaterialGoodsPicExample materialGoodsPicExample) {
        return materialGoodsPicService.selectByExample(materialGoodsPicExample);
    }

    @Override
    public List<MaterialGoods> selectByExample(MaterialGoodsExample materialGoodsExample) {
        return materialGoodsService.selectByExample(materialGoodsExample);
    }

    @Override
    public List<MaterialGoodsTypeBig> selectByExample(MaterialGoodsTypeBigExample materialGoodsTypeBigExample) {
        return materialGoodsTypeBigService.selectByExample(materialGoodsTypeBigExample);
    }

    @Override
    public List<MaterialGoodsTypeMiddle> selectByExample(MaterialGoodsTypeMiddleExample materialGoodsTypeMiddleExample) {
        return materialGoodsTypeMiddleService.selectByExample(materialGoodsTypeMiddleExample);
    }

    @Override
    public List<MaterialGoodsTypeSmall> selectByExample(MaterialGoodsTypeSmallExample materialGoodsTypeSmallExample) {
        return materialGoodsTypeSmallService.selectByExample(materialGoodsTypeSmallExample);
    }

    @Override
    public MaterialShop selectByExample(MaterialShopExample materialShopExample) {
        List<MaterialShop> result=materialShopMapper.selectByExample(materialShopExample);
        if (null != result && result.size() > 0) {
            return result.get(0);
        }
        return null;
    }

    @Override
    public int installShop(MaterialShop materialShop) {

        return materialShopMapper.insert(materialShop);
    }

    @Override
    public MaterialGoods installGoods(MaterialGoods materialGoods) {
        materialGoodsService.insert(materialGoods);
        return materialGoods;
    }
    @Override
    public MaterialGoodsModel installGoodsModel(MaterialGoodsModel materialGoodsModel) {
        materialGoodsModelService.insert(materialGoodsModel);
        return materialGoodsModel;
    }
    @Override
    public MaterialGoodsModelPin installGoodsPin(MaterialGoodsModelPin materialGoodsModelPin) {
        materialGoodsModelPinService.insert(materialGoodsModelPin);
        return materialGoodsModelPin;
    }

    @Override
    public List<MaterialGoods> selectGoodsByExampleForOffsetPage(MaterialGoodsExample example, Integer offset, Integer limit) {
        return materialGoodsService.selectByExampleForOffsetPage( example, offset,limit);
    }

    @Override
    public long countGoodsByExample(MaterialGoodsExample example) {
        return materialGoodsService.countByExample(example);
    }

    @Override
    public MaterialGoods selectByGoods(MaterialGoodsExample example) {

        return materialGoodsService.selectFirstByExample(example);
    }

    @Override
    public MaterialGoodsModelPin selectModelPin(MaterialGoodsModelPinExample materialGoodsModelPinExample) {
        return materialGoodsModelPinService.selectFirstByExample(materialGoodsModelPinExample);
    }
    @Override
    public MaterialGoodsTypeMiddle selectMiddle(MaterialGoodsTypeMiddleExample materialGoodsTypeMiddleExample) {

        return materialGoodsTypeMiddleService.selectFirstByExample(materialGoodsTypeMiddleExample);
    }

    @Override
    public MaterialGoodsTypeSmall selectSmall(MaterialGoodsTypeSmallExample materialGoodsTypeSmallExample) {
       return materialGoodsTypeSmallService.selectFirstByExample(materialGoodsTypeSmallExample);

    }

    @Override
    public MaterialGoodsTypeBig selectBig(MaterialGoodsTypeBigExample materialGoodsTypeBigExample) {
        return materialGoodsTypeBigService.selectFirstByExample(materialGoodsTypeBigExample);
    }

    @Override
    public int updateGoods(MaterialGoods materialGoods) {
       int count= materialGoodsService.updateByPrimaryKeySelective(materialGoods);
        return count;
    }

    @Override
    public int updateGoodsModel(MaterialGoodsModel materialGoodsModel) {
        int count= materialGoodsModelService.updateByPrimaryKeySelective(materialGoodsModel);
        return count;    }
    public int delectGoods(int id){
        return materialGoodsService.deleteByPrimaryKey(id);
    }
    public int delectModels(MaterialGoodsModelExample example){
        return  materialGoodsModelService.deleteByExample(example);
    }

    @Override
    public int updateGoodsModelPin(MaterialGoodsModelPin materialGoodsModelPin) {
        return materialGoodsModelPinService.updateByPrimaryKey(materialGoodsModelPin);
    }

    @Override
    public int delectGoodsModelPin(MaterialGoodsModelPinExample materialGoodsModelPinExample) {
        return materialGoodsModelPinService.deleteByExample(materialGoodsModelPinExample) ;
    }

    @Override
    public List<MaterialGoods> selectByPrimaryCity(MaterialGoodsExample  example,int offset,int limit) {
        return  materialGoodsService.selectByPrimaryCity(example,offset,limit);
    }
    public  int countByCityExample(MaterialGoodsExample example){
        return  materialGoodsService.countByCityExample(example);
    }

    @Override
    public List<MaterialGoods> selectByPrimaryDistance(int regionNumber, int typeId, int status, long min0, long max0,
                                                       long min1, long max1, long min2, long max2,
                                                       long min3, long max3,
                                                       long min4, long max4,
                                                       long min5, long max5,
                                                       long min6, long max6,
                                                       long min7, long max7,
                                                       long min8,long max8) {
        return materialGoodsMapper.selectByPrimaryDistance(regionNumber,typeId,status, min0,max0,min1,max1,min2,max2,min3,max3,min4,max4,min5,max5,min6,max6,min7,max7,min8,max8);

    }
}
